package com.john.ishadowsocks.auto.ui;

import com.john.ishadowsocks.auto.util.SwingUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

/**
 * 〈一句话功能简述〉<br/>
 * 〈功能详细描述〉
 *
 * @author jiangguangtao on 2016/5/20.

 */
public class MainFrame extends JFrame {
    private static final Logger log = LoggerFactory.getLogger(MainFrame.class);

    private final JFrame rootFrame;


    public MainFrame(String title) throws HeadlessException {
        super(title);
        rootFrame = this;
        setupWindow();
    }

    private void setupWindow() {
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setDefaultLookAndFeelDecorated(true);
        int width = 450;
        int height = 250;
        setSize(width, height);
        Point point = SwingUtils.getCenterPosition(width, height);
        setLocation(point);
//        URL imgURL = getClass().getClassLoader().getResource("icon.png");
//        setIconImage(Toolkit.getDefaultToolkit().getImage(imgURL));

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
//            log.warn("设置默认外观异常");
        }
    }
}
